<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Test Case for Issue #846</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>

<h1>Issue #846</h1>

<p>This test-case is intended for <a href="http://code.google.com/p/fbug/issues/detail?id=846">Issue #846</a>
- <span class="h3">Wrong data with XMLHttpRequest</span>.
<br/>
<i>Jan Odvarko, odvarko@gmail.com</i>
</p>

<ol>
<li>Click on the <i>Generate Requests</i> button. It will start to generate 5 requests.</li>
<li>Wait till all the requests are finished. Watch this status:
    <b><span id="Status">Not started yet</span></b></li>
<li>Activate the Console panel and check all responses. They should be all different (it's time stamp).</li>
</ol>

<br/><br/>

<button id="Button" onclick="runTest()">Generate Requests</button>

<br/><br/>

<script type="text/javascript">
    var counter = 0;
    var status = document.getElementById("Status");
    var button = document.getElementById("Button");
    var responses = [];

    function runTest()
    {
        load();
    }

    function load()
    {
        button.disabled = true;

        status.innerHTML = (counter+1) + ". request in progress...";

        var request = new XMLHttpRequest();
        request.onreadystatechange = function() 
        {
            if (request.readyState == 4 && request.status == 200) 
            {
                responses.push(request.responseText);

                if (counter < 4) 
                {
                    counter++;
                    setTimeout("load()", 100);
                }
                else 
                {
                    status.innerHTML = (counter+1) + ". request finished - DONE";
                    button.disabled = false;
                    counter = 0;
                }
            }
        }

        var time = (new Date()).getTime();
        request.open("POST", "Issue846.php", true);
        request.send(counter);
    }
</script>
</body>
</html>
